﻿<script>
    var KC = {
        keywords: [],
        trigger: $('[zyf-keyword-input]'),
        getName: function () {
            return $.trim(this.trigger.val());
        },
        indexOf: function () {
            return this.keywords.indexOf(this.getName());
        },
        add: function () {
            this.keywords.push(this.getName(this.trigger));
        },
        remove: function (name) {
            this.keywords.splice(this.keywords.indexOf(name), 1);
        },
        serialize: function () {
            return this.keywords.join(' ');
        },

        getNameByBadge: function ($badge) {
            return $.trim($badge.text());
        },
        setBadge: function (name) {
            let text = name || this.getName(this.trigger);
            return $('<span class="badge badge-pill badge-secondary hover-hand mr-1" zyf-keyword-new>' + text +
                ' <small zyf-keyword-remove style="margin-left:5px;"><span class="fa fa-times"></span></small>' +
                '</span>');
        },
        clear: function () {
            this.trigger.val("");
        },
        ajaxUrl: "/Career/HasUsed?name="
    };
</script>
